<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03_函数</title>
</head>
<body>
<button onclick="alert('警告框')">弹出警告框</button>
<button onclick="confirm('您确认退出登录吗？')">弹出确认框</button>
<button onclick="prompt('请输入用户名')">弹出输入框</button>
<script>
    console.log(parseInt(6.6));
    console.log(parseInt('6.6'));
    console.log(parseInt('6.1'));
    console.log(parseInt(6));
    console.log(parseInt('abc123'));//NaN
    console.log(parseInt('abc'));//NaN
    console.log(parseInt('123abd456sds sdf'));//123
    console.log('~~~~~~~~~~~~~~~~~~~~~');
    console.log(parseFloat(6.6));
    console.log(parseFloat('6'));
    console.log(parseFloat('6.1'));
    console.log(parseFloat(6));
    console.log(parseFloat('abc123'));//NaN
    console.log(parseFloat('1.2abc3.4'));//1.2
    console.log('~~~~~~~~~~~~~~~~~~~~~');
    console.log(isNaN('hhh'));
    function show() {
        console.log('show');
    }

    for (let i = 0; i < 10; i++) {
        show();
    }

    function f(n) {//形参
        console.log(n);
    }
    f(1);//实参
    f('hello');
    f(true);
    console.log('~~~~~~~~~~~~~~~~~~~~~');
    function f2(x, y) {//形参个数可以羽实参不一致
        console.log(x + y);
    }
    f2(1, 2);
    f2(1);//实参少于形参个数，未被赋值的形参值为undefined,1+undefined=NaN
    f2(3, 2, 1);//实参超过形参个数，多余的参数会被忽略
    console.log('~~~~~~~~~~~~~~~~~~~~~');
    function f3() {//arguments用来保存调用函数时传入的参数,可以看到参数的个数与具体的值
        console.log(arguments);
    }
    f3(1, 2, 3, 4, 5);
    f3(1);
    f3(1, 2, 3, 4, 5, 6, 7, 8, 9);
    f3(1, 2, 3, 4);
    console.log('~~~~~~~~~~~~~~~~~~~~~');
    function f4(x, y) {
        return x + y;
    }
    var result = f4(1, 2);
    console.log(result);
    console.log(f4(1, 2));
    console.log('~~~~~~~~~~~~~~~~~~~~~');
    var f5 = function () {
        console.log('hello');
    }
    f5();
    console.log(f5, typeof f5);
    console.log('~~~~~~~~~~~~~~~~~~~~~');
    const f6 = (n)=>{
        console.log('箭头函数' + n);
    }
    f6(1);
    f6('hello');
    console.log(f6, typeof f6);
</script>
</body>
</html>